package leetcode.array;

import java.util.Arrays;

/**
 * @author mazouri
 * @create 2021-05-02 18:34
 * <p>
 *
 * 来源：力扣（LeetCode）
 * 链接：https://leetcode-cn.com/problems/two-sum
 */
public class TwoSum {
    public static int[] twoSum(int[] nums, int target) {
        int[] returnArr = new int[2];
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] + nums[j] == target) {
                    returnArr[0] = i;
                    returnArr[1] = j;
                    break;
                }
            }
        }
        return returnArr;
    }

    public static void main(String[] args) {
        int[] nums ={2, 7, 11, 15};
        System.out.println(Arrays.toString(twoSum(nums, 9)));
    }
}
